package ljl.alg.jianzhioffer.round2;

public class _21_adjust_odd_even_in_array {
    
    /*
    * 脑残题
    *
    * 我解法和答案完全一样，但是我不骄傲
    * 因为太简单了！
    * 就像我拉的屎，和爱因斯坦一样，那啥也说明不了
    *
    * 这么说好吗？
    * */
    public int[] exchange(int[] nums) {
        int from = 0, to = nums.length - 1;
        while (from < to) {
            while (from < to && (nums[from] & 1) == 1) from++;
            while (from < to && (nums[to] & 1) == 0) to--;
            int t = nums[from];
            nums[from] = nums[to];
            nums[to] = t;
        }
        return nums;
    }
}
